<?php 
namespace app\models;
use Yii;
use yii\db\ActiveRecord;
use yii\base\ErrorException;
class Album extends ActiveRecord
{
    public static function tableName()
    {
        return 'album';
    }
    /*
        
        verification方法验证上传的url
    */
     public static function saveToDb($date)
    {
    	    $album = new Album();
            // "/demo/backend/web/".
            $url = $date;
             $album->url = $url;            
             if($album->verification($url))
             {
                 $album->save();                               	             
             }
             else       
                 return false;        
    }
      // 查找数据库中有无与$imageName相同。
    public function verification($url)
      {
          $y = Album::find()->where(['url'=>$url])->one();
          if($y==null)
            return true;
      }
 }
